using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;

namespace MapSurface.UIModelElement
{
     public class UIModel
    {
        private XmlNode _node;

        public XmlNode Node
        {
            get { return _node; }
            set { _node = value; }
        }
        private string _name;

        public string Name
        {
            get { return _name; }
            set { _name = value; }
        }
        private List<UIElement> _contains;

        public List<UIElement> Contains
        {
            get { return _contains; }
            set { _contains = value; }
        }
        private string _xmiFile;

        public string XmiFile
        {
            get { return _xmiFile; }
            set { _xmiFile = value; }
        }
        private APIModelManager _myAPIModel;

        public APIModelManager APIModel
        {
            get { return _myAPIModel; }
            set { _myAPIModel = value; }
        }

        public string toString()
        {
            string space = " ";
            string ret = "<?xml version=\"1.0\" encoding=\"ASCII\"?>\n";
            ret+="<UIModel:UIModel xmi:version='2.0' xmlns:xmi='http://www.omg.org/XMI' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:Interactions='http://interactions/1.0' xmlns:UIModel='http://uimodel/1.0' xsi:schemaLocation=\"http://uimodel/1.0 ../../../mapmodels/model/UIModel/UIModel.ecore http://interactions/1.0 /mapmodels/model/Interactions/InteractionsModel.ecore\" name='"+_name+"'>\n";
            if (_contains != null && _contains.Count > 0) 
                foreach( UIElement e in _contains)
                    try
                    {
                        ret += (space + ((Container)e).toString(true,space + " "));
                    }catch(InvalidCastException)
                    {
                        ret += (space + e.toString(space + " ") );
                    }

            ret += "</UIModel:UIModel>\n";
            return ret;
        }
  
    }

}

